#include <iostream>
#include <memory>
#include "Dict.hpp"
#include "udpsever.hpp"

// 用来测试的
std::string test1(const std::string &msg)
{
    std::string hello = "测试接口, ";
    hello += msg;
    return hello;
}

int main(int argc, char *argv[]){
     if(argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " port" << std::endl;
        return 1;
    }
    // std::string ip = argv[1];
    uint16_t port = std::stoi(argv[1]);
    Enable_Console_Log_Strategy();
    Dict dict;
    dict.LoadDict();
    
    std::unique_ptr<UdpSever> usvr = std::make_unique<UdpSever>(port, [&dict](const std::string &word, InetAddr&cli)->std::string{
        return dict.Translate(word, cli);
    });
    usvr->Init();
    usvr->Start();
}